home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sprite 1984 - 1993
/
Sprite 1984 - 1993.iso
/
src
/
lib
/
c
/
etc
/
RCS
/
getpass.c,v
< prev
next >
Wrap
Text File
|
1992-03-27
|
2KB
|
152 lines
head 1.5;
branch ;
access ;
symbols ;
locks ; strict;
comment @ * @;
1.5
date 92.03.27.12.25.11; author shirriff; state Exp;
branches ;
next 1.4;
1.4
date 89.06.15.12.59.12; author ouster; state Exp;
branches ;
next 1.3;
1.3
date 88.07.28.17.47.31; author ouster; state Exp;
branches ;
next 1.2;
1.2
date 88.07.25.10.45.46; author ouster; state Exp;
branches ;
next 1.1;
1.1
date 88.06.26.15.15.02; author ouster; state Exp;
branches ;
next ;
desc
@@
1.5
log
@Modified to allow long passwords.
@
text
@#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@@(#)getpass.c 5.2 (Berkeley) 3/9/86";
#endif LIBC_SCCS and not lint
/* Taken from 4.3 BSD; cannot be redistributed except to people with
* proper AT&T source licenses. */
#include <stdio.h>
#include <signal.h>
#include <sgtty.h>
#include <pwd.h>
char *
getpass(prompt)
char *prompt;
{
struct sgttyb ttyb;
int flags;
register char *p;
register c;
FILE *fi;
static char pbuf[_PASSWORD_LEN + 1];
void (*sig)();
extern char *getenv();
p = getenv("TTY");
if ((p != NULL) && ((fi = fopen(p, "r")) != NULL))
setbuf(fi, (char *)NULL);
else
fi = stdin;
sig = signal(SIGINT, SIG_IGN);
ioctl(fileno(fi), TIOCGETP, (char *) &ttyb);
flags = ttyb.sg_flags;
ttyb.sg_flags &= ~ECHO;
ioctl(fileno(fi), TIOCSETP, (char *) &ttyb);
fprintf(stderr, "%s", prompt); fflush(stderr);
for (p=pbuf; (c = getc(fi))!='\n' && c!=EOF;) {
if (p < &pbuf[_PASSWORD_LEN])
*p++ = c;
}
*p = '\0';
fprintf(stderr, "\n"); fflush(stderr);
ttyb.sg_flags = flags;
ioctl(fileno(fi), TIOCSETP, (char *) &ttyb);
signal(SIGINT, sig);
if (fi != stdin)
fclose(fi);
return(pbuf);
}
@
1.4
log
@Changed to conform to new signal handler type.
@
text
@d10 1
d21 1
a21 1
static char pbuf[9];
d37 1
a37 1
if (p < &pbuf[8])
@
1.3
log
@Lint.
@
text
@d21 1
a21 2
int (*signal())();
int (*sig)();
@
1.2
log
@Lint.
@
text
@d31 1
a31 1
ioctl(fileno(fi), TIOCGETP, &ttyb);
d34 1
a34 1
ioctl(fileno(fi), TIOCSETP, &ttyb);
d43 1
a43 1
ioctl(fileno(fi), TIOCSETP, &ttyb);
@
1.1
log
@Initial revision
@
text
@d23 1
d25 4
a28 1
if ((fi = fdopen(open("/dev/tty", 2), "r")) == NULL)
a29 2
else
setbuf(fi, (char *)NULL);
@